* Program to analyse SDC thresholds data * Created 13th Sept 2019 by Felix Ritchie * * * Last modified: * dd.mm.yy vxx Who * quietly { * set up capture log close set more off clear all local vers_no = "01" * Macros to run the code - change these local use_uniform = 1 local n_obs 500 local analyses_to_run = "simulated actual" * local analyses_to_run = "simulated" local working_folder = "C:\Users\fj-ritchie\OneDrive - UWE Bristol (Staff)\research\papers\10 is the safest number" * Show usefu8l information local logfile = "`working_folder'\\analysis_v`vers_no'_uniform`use_uniform'_`analyses_to_run'.smcl" log using "`logfile'", replace set linesize 255 local uniform = "e" if `use_uniform' { local uniform = "u" } local data_name = "`working_folder'\results_`uniform'`n_obs'_case" noisily display "*****************************************************" noisily display "Run parameters:" noisily display "Version no : `vers_no'" noisily display "Uniform age dist : `use_uniform'" noisily display "Log file : `logfile'" noisily display "*****************************************************" * Now loop for each of the simulated data, teh LFS and the charity data foreach source in `analyses_to_run' { local bycol = "src" local byrow = "" local ext = "act" if "`source'" == "simulated" { local ext = "sim" local byrow = "ypc" } noisily display "Source: `source'" forvalues type = 1/3 { noisily display "Case `type'... Loading `data_name'`type'_`ext'.dta..." use "`data_name'`type'_`ext'.dta" , clear local num_its = 0 if "`source'" == "simulated" { local num_its = it_no[_N]+1 local bycol = "zpc" if `type'==2 { local bycol = "qpc" } if `type'==3 { local bycol = "wpc" } } noisily display "Number of iterations (for simulations): `num_its'" noisily display "Number of observations (for simulations): `num_obs'" noisily tab bad_prop threshold capture noisily tab ok1_prop threshold capture noisily tab ok2_prop threshold capture noisily tab ok3_prop threshold capture noisily tab ok4_prop threshold noisily table threshold problems `bycol' , by(`byrow') if "`source'" == "simulated" { collapse (mean) bad_prop, by(threshold `bycol' `byrow') gen thr_sq = threshold^2 noisily regress bad_prop threshold thr_sq `byrow' `bycol' } else { noisily table threshold bad_prop src capture noisily table thr ok1 src capture noisily table thr ok2 src capture noisily table thr ok3 src capture noisily table thr ok4 src } } } log close }